<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主广告管理</title>
<link rel="stylesheet" type="text/css" href="template/admin.css"/>
<script type="text/javascript" src="template/images/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('.q').find('ul li').click(function(){
		$index=$('.q').find('ul li').index(this);
		$('#tb').find('div').eq($index).show().siblings().hide();
	});
	$('#sl_all').click(function(){
		$('table').find('#all').attr('checked','checked');
	});
	$('#show_list').find('tr').hover(function(){
		$(this).find('td').css('background','#ccffcc');
	},function(){
		$(this).find('td').css('background','');
	});
	
	//ajax修改排序
	$('.table_info1').find('#order_num').click(function(){
		$has_input=$(this).find('input').size();
		if(!$has_input){	
		$order=$(this).find('span').html();
		$id=$(this).find('span').attr('id');
		$(this).empty();	
		$('<input id="'+$id+'" style="width:30px;padding:1px 0" value="'+$order+'"/>').bind("blur",function(){
			if(!/^[0-9]+$/.test($(this).val())){
				alert("只能是数字");
				return;
			}
			
			$action = "ajax_order";
			$.ajax({
				type:'POST',
				url:'admin_flash_ad.php',
				data:'action='+$action+'&order_id='+$(this).val()+'&id='+$(this).attr('id'),
				success:function(msg){
					
				}
			});
			
			$('<span id="'+$(this).attr('id')+'">'+$(this).val()+'</span>').appendTo($(this).parent());
			$(this).remove();
		}).appendTo($(this));
		}
	}).hover(function(){
		$(this).addClass('on_order');
	},function(){
		$(this).removeClass('on_order');
	});
	
	
});
</script>
<?php
	$tech_num = (count($tech_arr)-1);
	$show_tech = $tech_arr[rand(0,$tech_num)];
?>
<script type="text/javascript">
	$(document).ready(function(){
		$str = '<?php echo $show_tech;?>';
		$('#show_tech').html("<em>小提示：</em>"+$str).fadeIn('slow');
	});
</script>
</head>

<body>
<div class="admin_position"><span>当前位置 > 主广告管理</span><p id="show_tech" style="display:none"></p></div><!--位置-->
		<div class="lang">
			<ul>
			 <?php
 $cache_file=DATA_PATH."cache/lang_cache.php";
 $cache_arr=read_cache($cache_file,'lang_cache');
 if(!empty($cache_arr)){
 foreach($cache_arr as $k=>$v){
  if(!$v['lang_is_use']){continue;}
 ?>
 <li><a href="?lang=<?php echo $v['lang_tag'];?>" class="<?php if($GLOBALS['lang']==$v['lang_tag']){echo 'hover';}?>"><?php echo $v['lang_name'];?></a></li>
 <?php
 }
 }
 ?>
			</ul>
		</div><!--语言-->
		
<div class="order_contain">		
<form name="maininfo" method="post" class="form">
<div class="list_sl_btn">
	<ul>
	<li><select name="cate_id" style="width:200px; margin-top:2px;">
	<option value="">请选择栏目</option>
	<?php
if(!empty($cate_rel)){
 foreach($cate_rel as $row){
 	$ck='';
 	if($row['id']==$cate_id){$ck='selected=selected';}
	echo "<option value=\"{$row['id']}\" {$ck}>{$row['cate_name']}</option>";
  }
  }
  ?>
	</select></li>
	<li><input type="button" name="sousuo" value="搜索" class="go" onclick="javascript:this.form.action='admin_flash_ad.php?action=flash_ad&lang=<?php echo $lang;?>';this.form.submit();" /></li>
	</ul>
</div>

<div class="order_main">
 <table cellpadding="0" cellspacing="0" width="100%" class="table_info1">
 	<thead>
		<tr><th class="w1" style="width:30%">图片</th><th class="w2" style="width:20%">链接地址</th><th style="width:30%">文字说明</th><th style="width:10%">排序</th><th class="w3 r" style="10%">操作</th></tr>
	</thead>
	<tbody id="show_list">
	<?php
	$maintb=DB_PRE."flash_ad";
	$page=empty($page)?1:$page;
	$pagesize=30;
	$pagenum=($page-1)*$pagesize;
	$filt="m.lang='{$lang}' and m.cate_id =".$cate_id;
	$query='&lang='.$lang.'&action=flash_ad&cate_id='.$cate_id;
	$order='order by m.id desc';
	$total_num=$GLOBALS['mysql']->fetch_rows("select m.id from {$maintb} as m where {$filt}");
	$total_page=ceil($total_num/$pagesize);
	$sql="select m.* from {$maintb} as m where {$filt} {$order} limit {$pagenum},{$pagesize}";
	$rel=$GLOBALS['mysql']->fetch_asc($sql);
	if(!empty($rel)){
	foreach($rel as $key=>$value){
	?>
		<tr>
		  <td class="w1" style="text-align:center; width:30%"><?php echo '<a href="../upload/'.$value['pic'].'" target="_blank" class="show_ad_pic">'.$value['pic'].'</a>';?></td><td class="w2" style="width:20%; text-align:center"><?php echo $value['pic_url'];?></td><td style="width:30%"><?php echo empty($value['pic_text'])?"&nbsp;":$value['pic_text'];?></th><td style="width:10%; text-align:center"><div id="order_num"><span id="<?php echo $value['id'];?>"><?php echo $value['pic_order'];?></span></div></th><td class="w3" style="text-align:center; width:10%"><a href="?action=edit&lang=<?php echo $lang;?>&id=<?php echo $value['id'];?>&cate_id=<?php echo $value['cate_id'];?>">修改</a>|<a href="javascript:if(confirm('确定要删除么,删除后将不可恢复!')){location.href='?action=del&lang=<?php echo $lang;?>&id=<?php echo $value['id'];?>';}">删除</a></td>
		</tr>
	<?php
	}
	}
	?>	
	</tbody>
 </table>
 </div>
 </form>

<div class="page page_fy">
 	<ul>
		<?php echo page('admin_flash_ad.php',$page,$query,$total_num,$total_page);?>
	</ul>
 </div>
 <div style="font-size:12px; color:#CCCCCC; padding:5px 0; text-align:center">powerd by <a href="http://fsai.cn" style="color:#CCCCCC" target="_blank">FOXSCMS</a></div>
 <div class="ie8-height"></div>
</div>
</body>
</html>
